<?php

require_once ('./View/bloggView.php');
require_once ('./Model/BloggList.php');

class NewPostController
{
	public function DoControll($database)
	{
		$outPut ="";
		$messegeId = 0;
		$messege="";

		$bv = new bloggView();
		$bl = new BloggList($database);

		if ($bv->TriedToSubmit())
		{
			$messegId = $bl->PostNewPost($bv->PostTitle(), $bv->NewPost(), $database);
		/*if ($messegeId == BloggList::TO_LONG)
			{
				$messege .= $bv->Message(BloggList::TO_LONG);
			}*/
		if ($messegeId == BloggList::TITLE_USED)
			{
				$messege .= $bv->Message(BloggList::TITLE_USED);
			}
		if ($messegeId == BloggList::POST_PASSED)
			{
				$messege .= $bv->Message(BloggList::POST_PASSED);
			}
		if ($messegeId == BloggList::POST_FAILED)
			{
				$messege .= $bv->Message(BloggList::POST_FAILED);
			}

		}

		$outPut .= $bv->DoNewPost();
		$outPut .= $messege;
		return $outPut;
	}
	
}


